package Thread2;

class MyThread2 extends Thread{
    @Override
    public void run() {
        System.out.println("hello Thread!");
    }
}

class MyRunnable2 implements Runnable{
    @Override
    public void run() {
        System.out.println("hello Thread!");
    }
}

public class homework1 {

    public static void main(String[] args) {
        //1. 继承Thread,重写run
        Thread t = new MyThread2();
        t.start();

        //2. 实现Runnable,重写run
        Runnable runnable = new MyRunnable2();
        Thread t2 = new Thread(runnable);
        t2.start();

        //3.继承Thread , 重写run 使用匿名内部类
        Thread t3 = new Thread(){
            @Override
            public void run() {
                System.out.println("hello Thread!");
            }
        };
        t3.start();

        // 4.实现Runnable,重写run,使用匿名内部类
        Runnable runnable2 = new Runnable() {
            @Override
            public void run() {
                System.out.println("hello Thread!");
            }
        };

        Thread t4 = new Thread(runnable2);
        t4.start();

        // 5. 使用lambda 表达式
        Thread t5 = new Thread(()->{
            System.out.println("hello Thread!");
        });

        t5.start();

        System.out.println("hello Main!");
    }

}
